<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>查看员工信息</title>
<link rel="stylesheet" type="text/css" href="css/index.css">
    <link rel="stylesheet" type="text/css" href="themes/metro/easyui.css">  
    <link rel="stylesheet" type="text/css" href="themes/mobile.css">  
    <link rel="stylesheet" type="text/css" href="themes/icon.css">  
    <script type="text/javascript" src="js/jquery.min.js"></script>  
    <script type="text/javascript" src="js/jquery.easyui.min.js"></script> 
    <script type="text/javascript" src="js/jquery.easyui.mobile.js"></script> 
    <script type="text/javascript"
	src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
</head>
<script type="text/javascript">
$(function(){
	$("#wb").hide()
	$("#xgmm").hide()
	$('#dg').datagrid({ 
		
	    url:'ygxx',    
	    columns:[[
	        {field:'ck',width:100,checkbox:true},
	        {field:'usernum',title:"用户名",width:90,hidden:true},
	        {field:'userpsw',title:"密码",width:90,hidden:true},
	        {field:'username',title:'姓名',width:90} ,
	        {field:'userage',title:'年龄',width:90},    
	        {field:'usersex',title:'性别',width:90},    
	        {field:'useridcard',title:'身份证号',width:110} ,
	        {field:'userborn',title:'出生日期',width:90},    
	        {field:'usernation',title:'民族',width:90},    
	        {field:'useraddress',title:'家庭住址',width:90} ,
	        {field:'usereducation',title:'学历',width:90} ,
	        {field:'userintime',title:'入职时间',width:90},    
	        {field:'userpositon',title:'职位',width:90},    
	        {field:'userremark',title:'备注',width:90} ,
	        {field:'userdepartment',title:"部门",width:90}   
	    ]],
	    //配置修改按钮
          toolbar : [ {
        	 
		  iconCls : 'icon-edit',
		  text : '修改信息',
		  handler : function() {
		  var users = $('#dg').datagrid('getSelections');
              if(users.length==1){
            	 $("#wb").show()
            	 //获取信息到文本框
            	  var usernum=$("#usernum").val(users[0].usernum)	
            	  var username=$("#username").val(users[0].username)
            	  var userage=$("#userage").val(users[0].userage)
            	  var usesex=$("#usersex").val(users[0].usersex)
            	  var useidcard=$("#useridcard").val(users[0].useridcard)
            	  var userborn=$("#userborn").val(users[0].userborn)
            	  var usernation=$("#usernation").val(users[0].usernation)
            	  var useraddress=$("#useraddress").val(users[0].useraddress)
            	  var usereducation=$("#usereducation").val(users[0].usereducation)
            	   $(function(){
            		   $("#win").window({
   						width : 500,
   						height : 500,
   						modal : true,
   						title : "请填写信息"
                      
   					})
            		  	$('#btn').linkbutton({
							onClick : function() {
								//获取文本输入的信息
								  var usernum=$("#usernum").val()
				            	  var username=$("#username").val()
				            	  var userage=$("#userage").val()
				            	  var usersex=$("#usersex").val()
				            	  var useidcard=$("#useridcard").val()
				            	  var userborn=$("#userborn").val()
				            	  var usernation=$("#usernation").val()
				            	  var useraddress=$("#useraddress").val()
				            	  var usereducation=$("#usereducation").val()
			                    //异步提交将信息传到后台
				            	  $.ajax({
				            		  url:"xiugai",
				            		  type:"post",
				                      data:{
				                    	"usernum" :usernum,
				                    	"username":username,
				                    	"userage":userage,  
				                        "usersex" :usersex,
				                        "useridcard":useidcard,
				                        "userborn" :userborn,
				                        "usernation":usernation,
				                        "useraddress":useraddress,
				                        "usereducation":usereducation,
				                      },
				            	       success:function(data){
				            	    	   if (data == "true") {
												$("#win").window("close");
												$.messager.alert('提示', '修改成功');
												$('#dg').datagrid('reload');
												
											} else {
												$.messager.show({
													title : '信息提示',
													msg : '修改失败',
													timeout : 1000,
													showType : 'slide'
												});
											}
				            	       }
				            	  })
							}
            		  	})
            	   }) 
            	  
					  
              } else {
					$.messager.confirm('提示', '必须选择一个', function(r) {
						if (r) {
							$('#dg').datagrid('uncheckAll');
						}
					}); 
              }
		}
	}],
	 
	});
	 toolbar: '#mima',
	$('#tb').textbox({    
	      
	    iconAlign:'left'       
	})
	toolbar:"#xg"
	//配置修改密码按钮
	$("#xg").linkbutton({
		onClick:function(){
			$("#xgmm").show()
			 $("#ckou").window({
					width : 400,
					height : 300,
					modal : true,
					title : "请填写信息"
              
				})
		}
	})
	
	$('#bt').bind('click', function(){    
		//配置form表单提交
		$('#xgmm').form({    
		    url:'xgmm',
		    onSubmit: function(){     
		    	//阻止表单提交 
				return $(this).form('enableValidation').form('validate');
		    },    
		    success:function(data){  
		    	  if(data=="true"){
			        	$("#ckou").window("close");
			        	$.messager.alert('提示', '修改成功');
			        
			        }else{
			        	$.messager.show({
			        		title:'信息提示',
			        		msg:'修改失败',
			        		timeout:1000,
			        		showType:'slide'
			        	})
			        }
		    }    
		});
		 $('#xgmm').submit();
    });
	 //密码格式验证
	$.extend($.fn.validatebox.defaults.rules, {    
	    equals: {    
	        validator: function(value,param){    
	            return value == $(param[0]).val();    
	        },    
	        message: "必须与上面保持一致"  
	    } ,
	    minLength: {    
	        validator: function(value, param){    
	            return value.length >= param[0];    
	        },    
	        message: '长度必须为4'   
	    } ,   

	    idcard : {// 验证身份证 
            validator : function(value) { 
                return /^\d{15}(\d{2}[A-Za-z0-9])?$/i.test(value); 
            }, 
            message : '身份证号码格式不正确' 
        },
      
        age : {// 验证年龄
            validator : function(value) { 
                return /^(?:[1-9][0-9]?|1[01][0-9]|100)$/i.test(value); 
            }, 
            message : '年龄必须是0到100之间的整数' 
        }, 
	    
	});  
	
	$("#useridcard").blur(function(card){
		 var reg = /^\d{17}[\w\d]$/;  
		   if(reg.test(card) === false)  
		   {  
			   $("#sfz").show()
		       return  false;  
		   }  
		
	})
		$('#quxiao').bind('click', function(){
			$('#xgmm').form('clear');
			$('#ckou').window('close');   
	    });
	
	  $("#qx").linkbutton({
		  onClick:function(){
			  $('#win').window('close');  
		  }
	  })
	
})


</script>
<body>
    <table id="dg">
     <div id="mima">
       <a href="#" id="xg" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true">修改密码</a>
    </div>
    </table> 
    
    <div id="win">
    <form id="xgxx" method="post">
    <div id="wb" style="margin-left:100px;line-height:40px">
        <input id="usernum" name="usernum" type="text" style="width:200px;display: none;">
        <br>
       
    &nbsp;&nbsp;姓名:<input id="username" name="username" style="width:180px" type="text" />
       <br>
    &nbsp;&nbsp;年龄:<input id="userage" name="userage" style="width:180px" type="text" class="easyui-validatebox" data-options="required:true,validType:'age'"/>
       <br>
    
    &nbsp;&nbsp;性别:<select id="usersex" name="usersex"  style="width:180px;">   
					    <option value="男">男</option>   
					    <option>女</option>        
					</select>  	
       <br>
       
           身份证号:<input id="useridcard" name="useridcard" style="width:180px" type="text" class="easyui-validatebox" data-options="required:true,validType:'idcard'"/>
      <br> 
           出生日期:<input id='userborn' name='userborn' style="width:180px" class="easyui-datebox" data-options="required:true"></input>	
    <br>
   
   &nbsp;&nbsp;民族:<select id="usernation" name="usernation"  style="width:180px;" >   
					    <option value="汉">汉族</option>   
					    <option value="回族">回族</option>
					     <option value="蒙古族">蒙古族</option>  
					    <option value="藏族">藏族</option>  
					    <option value="维吾尔族">维吾尔族</option>  
					    <option value="苗族">苗族</option>  
					    <option value="壮族">壮族</option>   
					    <option value="朝鲜族">朝鲜族</option>  
					    <option value="其它">其它</option>        
					</select>
      <br>
    
      家庭住址:<input id="useraddress" name="useraddress" style="width:180px" type="text" />
      <br>
     
   &nbsp;&nbsp;学历:<select id="usereducation" name="usereducation"  style="width:180px;">   
					    <option value="本科">本科</option>   
					    <option>博士研究生</option>
					    <option>硕士研究生</option>   
					    <option>专科</option>   
					    <option>高中</option>   
					    <option>中专</option>
					    <option>其它</option>         
					</select>  	
    
    
     <br>
    
     <a id="btn" href="#" class="easyui-linkbutton" style="margin-left:70px" data-options="iconCls:'icon-ok'">确定</a>
     <a id="qx" href="#" class="easyui-linkbutton"  data-options="iconCls:'icon-reload'">取消</a>
      </div>
      </form>
    </div>
   
    
    
    
    <div id="ckou">
    <form id="xgmm" method="psot">
    
    <div id="xgmm1" style="margin-top:20px;margin-left: 50px">
    &nbsp; &nbsp;旧密码: <input id="jiupsw" name="jiupsw" type="text"   value="${sessionScope.upsw}"/>  
        <br>
        <br>
  &nbsp; &nbsp;新密码: <input id="xinpsw" name="xinpsw" type="text" class="easyui-validatebox" data-options="validType:'minLength[4]'"/>   
   <br>
   <br>
    
 &nbsp;&nbsp;确认密码:<input id="qrnpsw" name="qrpsw" type="text" class="easyui-validatebox"     
    required="required" validType="equals['#xinpsw']"/>  
    <br>
    <br>
     <a id="bt" href="#" class="easyui-linkbutton" style="margin-left: 50px;">确定</a>
     <a id='quxiao' class="easyui-linkbutton" style="margin-left:60px">取消</a>
   </div>
   
   </form>
   </div>
   
</body>
</html>